<!-- 表单 》 视频 -->

<template>
  <el-form-item v-bind="formItem">
    <!-- 标签 -->
    <template v-if="hasLabelSlot" #label>
      <slot name="label" :label="formItem.label">{{ formItem.label }}</slot>
    </template>

    <draggable v-if="model.length" v-model="model" v-bind="draggableProps" @end="draged">
      <!-- 预览视频列表 (拖拽项) -->
      <div v-for="(item, i) in dataList" :key="item.id">
        <!-- 视频 -->
        <div :class="`${className}-player`">
          <video :src="item.path" controls />
        </div>

        <!-- 删除 -->
        <div :class="delClass" @click="toDel(i)">
          <img v-if="ICON.delImg" :src="ICON.delImg" />
          <i v-else :class="ICON.delIcon" />
        </div>
      </div>
    </draggable>

    <!-- 上传区域 -->
    <div :class="uploadClass" :style="uploadStyle">
      <el-upload v-bind="uploadProps">
        <div>
          <img v-if="ICON.upImg" :src="ICON.upImg" />
          <i v-else :class="ICON.upIcon" />

          <div v-if="text">{{ text }}</div>
        </div>
      </el-upload>
    </div>
  </el-form-item>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import FormFile from '../FormFile'

const name = 'FormVideo'

// ============================== 导出组件 ============================== //

export default CORE.extend(FormFile, {
  /**
   * 名称定义 (实际使用名称)
   */
  name,

  /**
   * 属性注册 (抽取以便查阅)
   */
  props: CORE.WEB[name],
})
</script>
